package com.focusai.efairy.model.request;

import com.focusai.efairy.model.base.UpLoadBaseEntity;
import com.focusai.efairy.network.Response;
import com.focusai.efairy.network.exception.ParseException;
import com.focusai.efairy.network.request.base.PureJSONRequest;
import com.focusai.efairy.network.utils.UrlUtils;
import com.focusai.efairy.utils.GsonHelper;

import org.json.JSONException;

import java.util.List;
import java.util.Map;

/**
 * Created by luo_guangwen on 2017/9/18.
 */

public class PostAnnounceItemRequest extends PureJSONRequest<String> {

    private UploadEntry uploadEntry;

    public PostAnnounceItemRequest(UploadEntry uploadEntry, Response.Listener<String> listener) {
        super(UrlUtils.createUrl("/appapi/announcement"), listener);
        this.uploadEntry = uploadEntry;
    }

    @Override
    protected String parse(String result) throws ParseException {
        return result;
    }

    @Override
    public Map<String, String> getParams() throws JSONException {
        return super.getParams();
    }

    @Override
    public String getPureJSON() throws JSONException {
        return GsonHelper.getInstance().toJson(uploadEntry);
    }

    public static class UploadEntry extends UpLoadBaseEntity {
        public List<Long> project_id_list;
        public int visibility_mode;
        public UploadAnnounceInfo efairyannouncement_info;
    }

    public static class UploadAnnounceInfo {
        public String efairyannouncement_title; // 公告标题
        public String efairyannouncement_content; // 公告内容
        public List<String> efairyannouncement_image_list; // 图片列表
    }
}


